<?php

/**
 * Rayon filter form base class.
 *
 * @package    appcemhti
 * @subpackage filter
 * @author     Steve Cancès
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseRayonFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_element'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Element'), 'add_empty' => true)),
      'id_balayage'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Balayage'), 'add_empty' => true)),
      'id_traitement' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Faisceau'), 'add_empty' => true)),
      'isotope'       => new sfWidgetFormFilterInput(),
      'charge'        => new sfWidgetFormFilterInput(),
      'energie'       => new sfWidgetFormFilterInput(),
      'fluence'       => new sfWidgetFormFilterInput(),
      'courantmoy'    => new sfWidgetFormFilterInput(),
      'courantmax'    => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'id_element'    => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Element'), 'column' => 'id_element')),
      'id_balayage'   => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Balayage'), 'column' => 'id_balayage')),
      'id_traitement' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Faisceau'), 'column' => 'id_traitement')),
      'isotope'       => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'charge'        => new sfValidatorPass(array('required' => false)),
      'energie'       => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'fluence'       => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'courantmoy'    => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'courantmax'    => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
    ));

    $this->widgetSchema->setNameFormat('rayon_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Rayon';
  }

  public function getFields()
  {
    return array(
      'id_rayon'      => 'Number',
      'id_element'    => 'ForeignKey',
      'id_balayage'   => 'ForeignKey',
      'id_traitement' => 'ForeignKey',
      'isotope'       => 'Number',
      'charge'        => 'Text',
      'energie'       => 'Number',
      'fluence'       => 'Number',
      'courantmoy'    => 'Number',
      'courantmax'    => 'Number',
    );
  }
}
